//
//  main.m
//  09-HomeWork
//
//  Created by dllo on 16/7/13.
//  Copyright © 2016年 dllo. All rights reserved.
//

#import <Foundation/Foundation.h>
#import "Person.h"
#import "Teacher.h"
#import "Student.h"
#import "NSMutableArray+convert.h"
int main(int argc, const char * argv[]) {
//    1.iOS9新特性三块的深入理解, 创建几个类, 熟悉写法(提交练习成果)
//    2.iOS 类扩展方式的复习 1> 给NSMutableArray添加convert方法，实现数组倒序。
//    3. 预习UI内容
   // 1.nullability
    Person *per = [[Person alloc] init];
    //1>nonnull
//    per.name = nil;
    per.name = @"haolin";
    NSLog(@"%@", per.name);
   //2>nullable
    per.sex = nil;
    NSLog(@"%@", per.sex);
    per.age = 12;
   //3>null_resettable
    per.friends = nil;
    NSLog(@"%@", per.friends);
    
  //2.泛型
   // 数组
    
    NSMutableArray *arr1 = [NSMutableArray array];
    [arr1 addObject:@"123"];
    [arr1 addObject:@12];
    NSLog(@"%@", arr1);
    NSMutableArray<NSString *> *arr2 = [NSMutableArray array];
    [arr2 addObject:@"123"];
//    arr2 添加了<NSString *> arr2 只能添加NSString类型的数据添加其它类型的数据会出现黄色警告
//    [arr2 addObject:@12];
    NSLog(@"%@", arr2);
  // 字典
    NSMutableDictionary<NSString *,NSString *> *dictionary = [NSMutableDictionary dictionary];
    [dictionary setObject:@"zhangsan" forKey:@"name"];
    NSLog(@"%@",dictionary);
//    字典泛型<NSString *,NSString *> 添加的age值应为NSString类型
//    [dictionary setObject:@22 forKey:@"age"];
    NSLog(@"%@", dictionary);
    Teacher<Student *> *teacher = [[Teacher alloc] init];
    Student *student1 = [[Student alloc] init];
    student1.name = @"zhangsan";
    Student *student2 = [[Student alloc] init];
    student2.name = @"lisi";
    [teacher addStudents:student1];
    [teacher addStudents:student2];
    [teacher removeStudents:student1];
  //协变(子类转为父类)和逆变（父类转子类）
    NSMutableArray *array1 = [NSMutableArray array];
    NSArray *array2 = [NSArray array];
    NSMutableArray *array3 = [NSMutableArray array];
    array1 = array3;
    array2 = [teacher returnArray];
    
   //2.Category
    NSMutableArray *mutableArr = [NSMutableArray arrayWithObjects:@"one", @"two", @"three", nil];
   NSMutableArray *convertArr =  [mutableArr convertForArray];
    NSLog(@"%@", convertArr);
   //extension    
    Person *loginPer = [[Person alloc] init];
    loginPer.name = @"xiaowan";
    [loginPer Login];
    return 0;
}
